{include file="public/header" /}
<body style="margin-bottom:70px;font-size:16px;">
	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="form-group has-feedback" style="margin-top:15px;">
					<span class="glyphicon glyphicon-search form-control-feedback"></span>
					<input id="search" type="text" class="form-control" placeholder="请输入课程名或老师名">
				</div>
			</div>
		</div>
	</div>
	{if(!empty($ad))}
		<div class="carousel slide" id="carousel">
			<ol class="carousel-indicators">
				{foreach($ad as $ad_k=>$ad_v)}
					<li data-slide-to="{$ad_k}" data-target="#carousel" {$ad_k==0?'class="active"':''}></li>
				{/foreach}
			</ol>
			<div class="carousel-inner">
				{foreach($ad as $ad_k=>$ad_v)}
					<div class="item {$ad_k==0?'active':''}">
						<a href="{$ad_v['url']}" target="_blank"><img alt="" src="{$ad_v['img']}" style="width:100%;" /></a>
					</div>
				{/foreach}
			</div>
			<a class="left carousel-control" href="#carousel" data-slide="prev">
				<span class="glyphicon glyphicon-chevron-left"></span>
			</a>
			<a class="right carousel-control" href="#carousel" data-slide="next">
				<span class="glyphicon glyphicon-chevron-right"></span>
			</a>
		</div>
	{/if}
	<div style="height:15px;background-color:#f5f5f5;margin:10px 0;"></div>
	<div id="newList">
		
	</div>

	<script type="text/javascript">
		var page = 1;
		list();
		$(window).scroll(function(){
			if($(window).scrollTop() == $(document).height() - $(window).height()){
				list();
			}
		});
		$('input').keydown(function(e){
			if(e.keyCode == 13){
				page = 1;
				list('s');
			}
		});
		function list(para=''){
			var data = {
				page : page
			};
			if(para == 's'){
				var search = $("#search").val();
				data.s = search;
			}
			$.post("/index.php/index/index/index_json",data,function(res){
				var list = '';
				if(res.code == 0){
					var list_length	=	res.data.length;
					for(var i=0;i<list_length;i++){
						list += '<div class="clearfix" style="padding-top:15px;padding-bottom:15px;" onclick="go_url(\'/index.php/index/index/details?id='+res.data[i].id+'\')">';
						list += '	<div>';
						list += '		<div class="col-xs-9">';
						list += '			<span style="font-size:20px;">'+res.data[i].title+'</span>';
						list += '		</div>';
						list += '		<div class="col-xs-3 text-right text-danger" style="margin-top:4px;">';
						if(res.data[i].tuition == 0){
							list += '			<span style="font-size:12px;">免费</span>';
						}else{
							list += '			<span style="font-size:12px;">￥'+res.data[i].tuition+'</span>';
						}
						list += '		</div>';
						list += '	</div>';
						list += '	<div style="margin-top:10px;">';
						list += '		<div class="col-xs-6 text-muted">';
						if(res.data[i].school.user.avatar){
							list += '			<img style="width:40px;height:40px;" src="'+res.data[i].school.user.avatar+'" alt="头像"/>';
						}else{
							list += '			<img style="width:40px;height:40px;" src="/static/index/images/user.jpg" alt="头像"/>';
						}
						list += '			<span style="font-size:14px;">'+res.data[i].teacher_name+'</span>';
						list += '		</div>';
						list += '		<div class="col-xs-6 text-right text-muted" style="margin-top:10px;">';
						list += '			<span style="font-size:14px;">'+res.data[i].school.school_name+'</span>';
						list += '		</div>';
						list += '	</div>';
						list += '</div>';
						list += '<div style="height:15px;background-color:#f5f5f5;margin:10px 0;"></div>';
					}
					if(page == 1){
						$("#newList").html(list);
					}else{
						$("#newList").append(list);
					}
					page++;
				}else{
					alert(res.errorMsg);
				}
			},'json');
		}
	</script>
	
	<div class="menu" style="padding-top:5px;">
		<div class="col-xs-6 text-center" onclick="go_url('/index.php/index/index/index')">
			<span class="glyphicon glyphicon-home"></span>
			<div class="menu_name">课程</div>
		</div>
		<div class="col-xs-6 text-center" onclick="go_url('/index.php/index/my/index')">
			<span class="glyphicon glyphicon-user"></span>
			<div class="menu_name">我的</div>
		</div>
	</div>
{include file="public/tail" /}